# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=pgbouncer
pkgver=1.21.0
pkgrel=0
pkgdesc="Lightweight connection pooler for PostgreSQL"
url="https://www.pgbouncer.org/"
arch="all"
license="ISC"
pkgusers="pgbouncer"
pkggroups="postgres"
install="$pkgname.pre-install"
makedepends="c-ares-dev libevent-dev openssl-dev>3 udns-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://www.pgbouncer.org/downloads/files/$pkgver/pgbouncer-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	pgbouncer-dirs.patch
	"

# secfixes:
#   1.16.1-r0:
#     - CVE-2021-3935

build() {
	./configure \
		--prefix=/usr \
		--disable-debug
	make
}

check() {
	make -C test
}

package() {
	make DESTDIR="$pkgdir" install

	cd "$pkgdir"
	install -m 755 -D "$srcdir"/$pkgname.initd ./etc/init.d/$pkgname
	install -m 644 -D "$srcdir"/$pkgname.confd ./etc/conf.d/$pkgname
	install -m 644 -D "$srcdir"/$pkgname.logrotate ./etc/logrotate.d/$pkgname
	install -m 644 -D "$builddir"/etc/$pkgname.ini ./etc/$pkgname/$pkgname.ini

	install -d -m 755 -o $pkgusers -g $pkggroups ./var/log/$pkgname
}

sha512sums="
881701deae508e8e664402c0da533b25027259443551cda2974867453ad033ec5cfe8027ca3dac96a5134c57faff385c3c1e5711539e1acd6815761c9e3caee8  pgbouncer-1.21.0.tar.gz
19d2637509ca34b105851cd0f3291ead6a1b991e687a6a5b561c9015abca477ecdf91eb7f999e1cb7c66490e47dd2fbb4f16cd34bff6fb29d7f76a4b739a0d8d  pgbouncer.initd
808621351b0f5973427fa22f63128432b00ac20fd25af437e8148dad9e55185775aba612b6ecdd58e4a6f2450b8c7838fcace288845b9b3cd0236bbe168aa574  pgbouncer.confd
83b869466b59c1b1d6e316a9368f725181128c1f5a7af230e3fa9c58ccda1bc097db182806c1c51a5121692791ec83d9eb0f5718fb3031f521bb537001153e2d  pgbouncer.logrotate
f45170465fda5190257e3f4c10e22fe7df57657efc90bdd6a3f0727375a25143e07480ecd998995cec0ddb2ed2d472f996b21e4fe712681418215823b88d0fc3  pgbouncer-dirs.patch
"
